import { createPinia,defineStore } from 'pinia'
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'
import { v4 as uuidv4 } from 'uuid';
const pinia = createPinia()
pinia.use(piniaPluginPersistedstate)

export default pinia

 const wmsStore = defineStore('wmsStore', {
  state: () => {
    return {
      nickName: '游客',
      isMenuCollapse:false,
      token:"",
      traceId:'',
      roles: <any>[],
      permissions: <any>[],
      tempPO:<any>[],
      tempOrder:<any>[],
      tempBatch:<any>[]
    }
  },
  getters:{
    getTraceId(state): string {
        state.traceId = state.traceId=="" ? uuidv4() : state.traceId
        return state.traceId
    }
  },
  actions: {
      setName(name: string) {
        this.nickName = name
      }
  },
  persist: {
    key: 'wms-store',
    storage: localStorage,
  },
})

export  {wmsStore}
 